package com.ruoyi.common.core.redis;

import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import org.springframework.data.redis.core.BoundSetOperations;

/**
 * 缓存接口
 * 在ruoyi-admin中用MysqlCache实现这个接口（依赖反转）， ruoyi-admin依赖的是ruoyi-common
 */
public interface ICache {
    <T> void setCacheObject(final String key, final T value);
    <T> void setCacheObject(final String key, final T value, final Integer timeout, final TimeUnit timeUnit);
    boolean expire(final String key, final long timeout);
    boolean expire(final String key, final long timeout, final TimeUnit unit);
    long getExpire(final String key);
    Boolean hasKey(String key);
    <T> T getCacheObject(final String key);
    boolean deleteObject(final String key);
    boolean deleteObject(final Collection collection);
    <T> long setCacheList(final String key, final List<T> dataList);
    <T> List<T> getCacheList(final String key);
    <T> BoundSetOperations<String, T> setCacheSet(final String key, final Set<T> dataSet);
    <T> Set<T> getCacheSet(final String key);
    <T> void setCacheMap(final String key, final Map<String, T> dataMap);
    <T> Map<String, T> getCacheMap(final String key);
    <T> void setCacheMapValue(final String key, final String hKey, final T value);
    <T> T getCacheMapValue(final String key, final String hKey);
    <T> List<T> getMultiCacheMapValue(final String key, final Collection<Object> hKeys);
    boolean deleteCacheMapValue(final String key, final String hKey);
    Collection<String> keys(final String pattern);
} 